import { backButton } from './allButton.js';

import { Tools, LocaleService,ICommandService,CommandType, UniverInstanceType,Plugin,IUniverInstanceService, DependentOn} from "@univerjs/core";
import {UniverSheetsPlugin  } from "@univerjs/sheets";
import { IMenuService, UniverUIPlugin,ComponentManager} from "@univerjs/ui";
import { IRenderManagerService} from "@univerjs/engine-render";
import { Inject, Injector } from '@wendellhu/redi';
import { ShareSingle,SaveSingle,BackSingle,DownloadSingle,PrintSingle } from '@univerjs/icons';
const SHEET_CUSTOM_MENU_PLUGIN = 'SHEET_CUSTOM_MENU_PLUGIN';
var gm = Object.defineProperty, 
ZP = Object.getOwnPropertyDescriptor, 
YP = 
(t, e, n) => e in t ? 
gm(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : 
t[e] = n, 
GP = (t, e, n, s) => {
  for (var i = s > 1 ? void 0 : s ? ZP(e, n) : e, r = t.length - 1, o; r >= 0; r--)
    (o = t[r]) && (i = (s ? o(e, n, i) : o(i)) || i);
  return s && i && gm(e, n, i), i;
}, 
cr = (t, e) => (n, s) => e(n, s, t), 
fm = (t, e, n) => (YP(t, typeof e != "symbol" ? e + "" : e, n), n);
let diyplugin= class extends Plugin {
    constructor(
        t = {}, e, n, s, i,j,k,l
    ) {
        super(), 
        this._config = t, 
        this._injector = e, 
        this._localeService = n, 
        this._renderManagerService = s, 
        this._univerInstanceService = i, 
        this._menuService=j;
        this._commandService=k;
        this._componentManager=l;
        this._config = Tools.deepMerge({}, {}, this._config);
       
    }
  
    
     onStarting() {
        //注册按钮图标
        // this._componentManager.register("sharicon", ShareSingle);
        // this._componentManager.register("saveicon", SaveSingle);
        this._componentManager.register("backicon", BackSingle);
        // this._componentManager.register("downloadicon", DownloadSingle);
        // this._componentManager.register("printicon", PrintSingle);
        //新增按钮
        // this._menuService.addMenuItem(sharButton);
        // this._menuService.addMenuItem(saveButton);
        
        // this._menuService.addMenuItem(downloadButton);
        this._menuService.addMenuItem(backButton);
        // this._menuService.addMenuItem(printButton);
        //新增命令(这个和上面那段新增按钮莫法分开,不然要报错)
        // const sharCommand = {
        //     id: "shar-button",             // command id, same as menu button id
        //     type: CommandType.OPERATION,
        //     handler: (accessor) => {
        //       return true;
        //     }
        // }
        // this._commandService.registerCommand(sharCommand);
        // const saveCommand = {
        //   id: "save-button",             // command id, same as menu button id
        //   type: CommandType.OPERATION,
        //   handler: (accessor) => {
        //     return true;
        //   }
        // }
        // this._commandService.registerCommand(saveCommand);
        const backCommand = {
          id: "back-button",             // command id, same as menu button id
          type: CommandType.OPERATION,
          handler: (accessor) => {
            return true;
          }
        }
        this._commandService.registerCommand(backCommand);
        // const downloadCommand = {
        //   id: "download-button",             // command id, same as menu button id
        //   type: CommandType.OPERATION,
        //   handler: (accessor) => {
        //     return true;
        //   }
        // }
        // this._commandService.registerCommand(downloadCommand);
        // const printCommand = {
        //   id: "print-button",             // command id, same as menu button id
        //   type: CommandType.OPERATION,
        //   handler: (accessor) => {
        //     return true;
        //   }
        // }
        // this._commandService.registerCommand(printCommand);
    }
    
}
fm(diyplugin, "pluginName", SHEET_CUSTOM_MENU_PLUGIN);
fm(diyplugin, "type", UniverInstanceType.UNIVER_SHEET);

diyplugin = GP([
  DependentOn(UniverSheetsPlugin, UniverUIPlugin),
  cr(1, Inject(Injector)),
  cr(2, Inject(LocaleService)),
  cr(3, IRenderManagerService),
  cr(4, IUniverInstanceService),
  cr(5, IMenuService),
  cr(6, ICommandService),
  cr(7, Inject(ComponentManager)),
], diyplugin);

export {diyplugin};